﻿using System;

namespace ProjectAutumn.Graphics
{
    public abstract class Texture : IDisposable
    {
        protected System.Drawing.Color ConvertColor(Color color)
        {
            unchecked
            {
                return System.Drawing.Color.FromArgb((int)color.PackedValue);
            }
        }
        public static Texture FromFile(GraphicsDevice graphicsDevice, string file)
        {
            return graphicsDevice.LoadTexture(file);
        }
        public static Texture CreateTexture(GraphicsDevice graphicsDevice, int width, int height)
        {
            return graphicsDevice.CreateTexture(width, height);
        }
        public void SetData(Color[] color)
        {
            if (color.Length != Width * Height)
                throw new Exception("Color array must be as big as Width * Height");
            SetData(color, 0, color.Length);
        }
        public abstract void SetData(Color[] color, int start, int length);
        public abstract int Width { get; }
        public abstract int Height { get; }
        public virtual void Dispose() { }
    }
}
